<?php

/**
 * @author      :   NhanVA
 * @name        :   Fpt_Business_Match
 * @copyright   :   Fpt Online
 * @todo        :   Match business
 */
class Fpt_Business_Match
{
    /**
     *
     * @var <type>
     */
    protected static $instances = null;

    /**
     * Constructor of class
     * we don't permit an explicit call of the constructor! (like $v = new Singleton())
     */
    protected function __construct()
    {
        //nothing
    }

    /**
     * Get instance of class
     *
     * @param string $className
     * @return Fpt_Business_Match_Adapter_Abstract
     */
    public final static function getInstance($options = array())
    {
        //Check class name
        $className = $options['adapter'] ;
        //If empty className
        if(empty($className))
        {
            return Fpt_Server::setOutputData(-1,'empty class name', null);
        }

        //Switch to get classname
        switch(strtolower($className))
        {
            case 'mysql':
                $className = 'Fpt_Business_Match_Adapter_MySql';
                break;
         
            default:
                return false;
                throw new Fpt_Business_Exception("No instance of class $className");
                break;
        }

        //Put to list
        if(!isset(self::$instances[$className]))
        {
            self::$instances[$className] = $className::getInstance();
        }

        //Return object class
        return self::$instances[$className];
    }


}

